package main

import (
	"fmt"
	"math"
	"time"

	"homework/util"
)

func main() {

	var ti = time.Now()
	var r = int(math.Ceil(88162 * 0.0001))
	var allMap = make([][]*util.ItemsAndCount, 0, 1<<13)
	var allCount = 0

	var l = util.CreateL1("./retail.dat", r)
	allMap = append(allMap, l.Iac)
	allCount += len(l.Iac)

	var c *util.C

	for i := 2; true; i++ {
		c = l.GenC()
		l = c.Scan(r)
		if len(l.Iac) != 0 {
			allMap = append(allMap, l.Iac)
			allCount += len(l.Iac)
		} else {
			break
		}
	}

	fmt.Println(time.Since(ti))
	for k, v := range allMap {
		fmt.Println("频繁", k+1, "项集", "有", len(v), "条")
	}
	fmt.Printf("总共有%d个\n", allCount)
	var rules = util.CalculateStrongRules1(allMap, 0.5)
	fmt.Printf("强规则有%d条\n", len(rules))

}
